<template>
  <div>
    <!--外层容器-->
    <el-container>
      <!--上半区域: 顶栏-->
      <el-header class="layout-header">
        <h1>物业管理系统</h1>
      </el-header>
      <!--下半区域-->
      <el-container class="layout-body">
        <!--下半区域的左侧边栏-->
        <el-aside class="layout-aside">
          <el-menu
              router
              :default-active="activeMenuItemPath"
              class="el-menu-vertical-demo"
              background-color="#222"
              text-color="#fff"
              active-text-color="#ffd04b">
            <el-menu-item index="/sys-admin/index">
              <i class="el-icon-s-home"></i>
              <span>主页</span>
            </el-menu-item>
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-s-tools"></i>
                <span>临时页面</span>
              </template>
              <el-menu-item index="/sys-admin/temp/admin/add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加管理员</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/temp/admin/list">
                <i class="el-icon-s-operation"></i>
                <span>管理员列表</span>
              </el-menu-item>

              <el-menu-item index="/sys-admin/temp/user/add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加用户</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/temp/user/list">
                <i class="el-icon-s-operation"></i>
                <span>用户列表</span>
              </el-menu-item>
            </el-submenu>

            <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-s-goods"></i>
                <span>缴费管理</span>
              </template>
              <el-menu-item index="1-1">
                <i class="el-icon-s-grid"></i>
                <span>SPU台账</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/product/spu/add-new-1">
                <i class="el-icon-circle-plus"></i>
                <span>新增SPU</span>
              </el-menu-item>
              <el-menu-item index="1-3">
                <i class="el-icon-picture"></i>
                <span>相册管理</span>
              </el-menu-item>
              <el-menu-item index="1-4">
                <i class="el-icon-s-unfold"></i>
                <span>商品类别</span>
              </el-menu-item>
              <el-menu-item index="1-5">
                <i class="el-icon-s-flag"></i>
                <span>属性模板</span>
              </el-menu-item>
              <el-menu-item index="1-6">
                <i class="el-icon-s-data"></i>
                <span>品牌管理</span>
              </el-menu-item>
            </el-submenu>

            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-s-check"></i>
                <span>客户服务</span>
              </template>
              <el-menu-item index="/sys-admin/temp/complaint/add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加投诉</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/temp/complaint/list">
                <i class="el-icon-s-operation"></i>
                <span>投诉列表</span>
              </el-menu-item>

              <el-menu-item index="/sys-admin/temp/advise/add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加建议</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/temp/advise/list">
                <i class="el-icon-s-operation"></i>
                <span>建议列表</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/temp/maintain/add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加维修</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/temp/maintain/list">
                <i class="el-icon-s-operation"></i>
                <span>维修列表</span>
              </el-menu-item>
            </el-submenu>

            <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-s-home"></i>
                <span>物业管理</span>
              </template>
              <el-menu-item index="/sys-admin/temp/car/add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加车辆</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/temp/car/list">
                <i class="el-icon-s-operation"></i>
                <span>车辆列表</span>
              </el-menu-item>
            </el-submenu>

            <el-submenu index="5">
              <template slot="title">
                <i class="el-icon-menu"></i>
                <span>基础信息</span>
              </template>
            </el-submenu>

            <el-submenu index="6">
              <template slot="title">
                <i class="el-icon-s-platform"></i>
                <span>系统管理</span>
              </template>
            </el-submenu>


          </el-menu>
        </el-aside>
        <!--下半区域的右侧主体-->
        <el-main class="layout-main">
          <!--由其他视图来显示-->
          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style>
.layout-header {
  background: forestgreen;
}

.layout-header h1 {
  color: #fff;
  line-height: 60px;
  font-size: 32px;
}

.layout-body {

  position: absolute;
  top: 60px;
  bottom: 0;
  left: 0;
  right: 0;
}

.layout-aside {
  background-color: #222;
}

.layout-aside i {
  color: #fff !important;
}

.layout-main {
  background-color: #ffffff;
}

.el-menu-item.is-active {
  background-color: #44444b !important;
}
</style>

<script>
export default {
  data() {
    return {
      activeMenuItemPath: ''
    }
  },
  mounted() {
    let path = this.$router.currentRoute.path;
    if (path.startsWith('/sys-admin/product/spu/add-new-')){
      path = '/sys-admin/product/spu/add-new-1';
    }
    this.activeMenuItemPath = path;
  }
}
</script>
